var mysql = require('mysql');

var pool = mysql.createPool({
    connectionLimit: 10,
    host: '127.0.0.1',
    port: '3306',
    database: 'mytemp',
    user: 'root',
    password: '123456'
});


var mysqlDao = function() {
    
    this.query = function(sql,callback){
        pool.getConnection(function(err,conn){
            if(err) {
                console.log('error');
            }else{
                conn.query(sql,function(err,rows,fields){
                    conn.release();
                    callback(rows);
                });
            }
        });
    };
}

module.exports = mysqlDao;

// var m = new mysqlDao();
// var sql = 'select * from eadept';
// m.query(sql,function(result){
//     console.log(result);
// });